import { NgModule } from '@angular/core';
import { RouterModule, Routes, PreloadAllModules } from '@angular/router';

import { AuthGuard } from './core';
import { LayoutComponent } from './layout/layout.component';

export const routes: Routes = [
  //这个模式,支持游客和登录模式,不登陆也可以看地图,
  {
    path: 'login',
    loadChildren: () => import('./auth/login.module').then(m => m.LoginModule),
  },
  {
    path: "",
    component: LayoutComponent,
    canActivate: [AuthGuard],
    children: [
      { path: '', redirectTo: 'overview', pathMatch: 'full' },
      {
        path: 'overview',
        loadChildren: () => import('./business/overview/overview.module').then(m => m.OverviewModule),
      },
      {
        path: 'plot',
        loadChildren: () => import('./business/plot/plot.module').then(m => m.PlotModule),
      }
      ,
      {
        path: 'polluts',
        loadChildren: () => import('./business/polluts/polluts.module').then(m => m.PollutsModule),
      },
      {
        path: 'repair',
        loadChildren: () => import('./business/repair/repair.module').then(m => m.RepairModule),
      },
      {
        path: 'board',
        loadChildren: () => import('./business/board/board.module').then(m => m.BoardModule),
      }
    ]
  }

];

@NgModule({
  imports: [
    RouterModule.forRoot(routes, {
      useHash: true,
      preloadingStrategy: PreloadAllModules,
      relativeLinkResolution: 'legacy'
    })
  ],
  exports: [RouterModule]
})
export class AppRoutingModule { }